import math


def cal_mod(n):
    result = []
    if(n==0):
        return [0]
    while (n != 0):
        result.append(n % 10)
        n = int(n / 10)
    return result


def check(n, i, ls):
    result = 0
    for j in ls:
        result = result + int(math.pow(j, n))
    return i == result


n = int(input("请输入n:"))
if(n==1):
    start=0
else:
    start = int(math.pow(10, n - 1))
end = int(math.pow(10, n))
for i in range(start, end):
    if (check(n, i, cal_mod(i))):
        print(i)
